package com.lagou.controller;

import com.lagou.config.RoutingDataSourceContext;
import com.lagou.config.RoutingWith;
import com.lagou.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Nocturne
 * @date 2021/5/9 23:47
 * @description
 */
@RestController
public class ProductController {
	@Autowired
	private ProductService productService;

	@RequestMapping("/findAllProductM")
	@RoutingWith("master")
	public String findAllProductM() {
		/*String key = "master";
		RoutingDataSourceContext routingDataSourceContext = new RoutingDataSourceContext(key);*/
		productService.findAllProductM();
		return "master";
	}

	@RequestMapping("/findAllProductS")
	@RoutingWith("slave")
	public String findAllProductS() {
		/*String key = "slave";
		RoutingDataSourceContext routingDataSourceContext = new RoutingDataSourceContext(key);*/
		productService.findAllProductS();
		return "slave";
	}


}
